package com.jy.task.utils;

import java.util.Date;

import org.springframework.context.ApplicationContext;

import com.jy.common.utils.SpringWebContextUtil;
import com.jy.common.utils.base.UuidUtil;
import com.jy.entity.filemanager.TSLog;
import com.jy.service.filemanager.operlog.OperLogService;

public class TaskOperLogUtil {
	/** 日志对象 */

	private static OperLogService service;

	public final static int NORMAL = 1;

	public final static int EXCEPTION = 2;

	public static OperLogService getTaskLogService() {
		if (service == null) {
			ApplicationContext ac = SpringWebContextUtil
					.getApplicationContext();
			service = (OperLogService) ac.getBean("operLogService");
		}
		return service;
	}

	public static void saveTaskLog(int operType, String operPage,
			String operInfo) {

		TSLog o = new TSLog();
		o.setId(UuidUtil.get32UUID());
		o.setOperType(operType);
		o.setOperPage(operPage);
		o.setOperInfo(operInfo);
		saveTaskLog(o);

	}

	public static void saveTaskLog(TSLog o) {
		try {
			o.setCreateDate(new Date());
			getTaskLogService().insert(o);
		} catch (Exception e) {
		}
	}
}
